function Promise(exector) {
    var _this = this
    this.status = 'pending'
    this.value = undefined

    try {
      exector(resolve, reject)
    }catch(e) {
      reject(e)
    }

    function resolve(value) {
      if(_this.status === 'pending') {
        _this.status = 'fulfilled'
        _this.value = value
      }
    }

    function reject(value) {
      if(_this.status === 'pending') {
        _this.status = 'rejected'
        _this.value = value
      }
    }
  }

Promise.prototype.then = function(resolve, reject) {
  if(this.status === 'fulfilled') {
    resolve(this.value)
  }

  if(this.status === 'rejected') {
    reject(this.value)
  }
}

  new Promise((resolve, reject)=> {
    resolve('1')
  }).then((data)=> {
    console.log('resolve' + data)
  }, (data)=> {
    console.log('reject' + data)
  }) //resolve1

  new Promise((resolve, reject)=> {
    setTimeout(()=> {
      resolve('2')
    }, 1000)
  }).then((data)=> {
    console.log('resolve' + data)
  }, (data)=> {
    console.log('reject' + data)
  }) //无法正常输出